home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / SpinEvent.cc < prev    next >
C/C++ Source or Header  |  1990-07-09  |  821b  |  37 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. // 
  3. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  4. // Copyright (C) 1989 University of Colorado, Boulder, Colorado
  5. // Copyright (C) 1990 University of Colorado, Boulder, Colorado
  6. //
  7. // written by Dirk Grunwald (grunwald@foobar.colorado.edu)
  8. //
  9. #include "SpinEvent.h"
  10. #include "Pragma.h"
  11.  
  12. C_EXTERNAL_FUNCTION( int getpid() );
  13.  
  14. void
  15. SpinEvent::waitFor()
  16. {
  17.     int timesAround = 0;
  18.  
  19.     reserve();
  20.     int gen = generation;
  21.     garcon++;
  22.     release();
  23.  
  24.     //
  25.     // Waiting people just read generation, and the final process
  26.     // just writes it, so we do not really even need to use the locks here.
  27.     //
  28.     
  29.     while ( gen == generation ) {
  30.     if (timesAround > pLoops) {
  31.         (void) getpid();
  32.         timesAround = 0;
  33.     }
  34.     timesAround++;
  35.     }
  36. }
  37.